using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using UniversalAdmin.Domain.Repositories;
using UniversalAdmin.Infrastructure.Data.Contexts;
using UniversalAdmin.Infrastructure.Jwt;
using UniversalAdmin.Infrastructure.Repositories;
using UniversalAdmin.Shared.Constants;
using UniversalAdmin.Shared.Interface;

namespace UniversalAdmin.Infrastructure;

public static class ServiceCollectionExtension
{
    public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<AdminDbContext>(options =>
            options.UseNpgsql(configuration.GetConnectionString("postSql")));

        services.AddScoped(typeof(IRepositories<>), typeof(EfRepositories<>));
        
        services.AddScoped<IJwtService, JwtService>();
        return services;
    }
}
